@extends('admin.layouts.app')
@section('css')

@endsection
@section('content')

                        <div class="row">
                            <div class="col-sm-12">
                                <h4 class="page-title">工单管理</h4>
                                <ol class="breadcrumb">
                                    <li><a href="{{url('zadmin')}}">系统</a></li>
                                    <li><a href="{{url('zadmin/task')}}">工单列表</a></li>
                                    <li class="active">任务详情</li>
                                </ol>
                            </div>
                        </div>
                        
                        <div class="row">
                        	<div class="col-lg-12">
                        		<div class="card-box">
                            <h2 class="m-t-0 header-title">工单详情</h2>
                            
                             
      <div class="row">
			   <div class="col-md-9">
                                 
            <table class="table table-hover">
              
                <tr>
                  <th>工单号</th>
                  <td>{{$data->code}}</td>
                  <th>录单时间</th>
                  <td>{{$data->created_at}}</td>
                </tr>
                <tr>
                  <th>客户姓名</th>
                  <td>{{object_get($data,'client_name')}}</td>
                  <th>车辆</th>
                  <td>{{$data->car_brand}} {{object_get($data,'car_num')}}</td>
                </tr>
               
                <tr>
                  <th>送修日期</th>
                  <td>{{object_get($data,'arrived_at')}}</td>
                  <th>送修里程</th>
                  <td>{{$data->miles}}</td>
                </tr>
                <tr>
                  <th>维修类型</th>
                  <td>{{object_get($data,'maintain.name')}}</td>
                  <th>故障信息</th>
                  <td>{{$data->bug_info}}</td>
                </tr>
               
                
              
                <tr>
                  
                  <th>技师</th>
                  <td>{{object_get($data,'worker.truename')}}</td>
                  <th>完工时间</th>
                  <td>{{$data->completed_at}}</td>
                 
                </tr>
                {{--
               <tr>
                  <td colspan="2">
                    <a class="btn btn-primary btnPrint" href="{{url('zadmin/task/print',$data->id)}}" >打印</a>
                  </td>
                </tr>
                --}}
                <tr>
                  <th colspan="2">
                    总费用：<span class="label label-danger" style="font-size: 14px;"> {{$data->total_money}}</span>
                  </th>
                  <th>
                    付款方式 
                  </th>
                  <td>{{$data->balance_type}}</td>
                   
                </tr>
                <tr>
                  <th>当前状态</th>
                  <td colspan="3"><a class="btn btn-{{$data->status_style}}  btn-sm" href="{{url('zadmin/task/complete')}}?task_id={{$data->id}}">{{$data->status_txt}}</a></td>
                </tr>
                <tr>
                  <td colspan="2">
                    <button class="btn btn-default btnPrint">打印</button>
                  </td>
                  <td colspan="2">
                    @if($data->status!=100)
                    <a href="{{url('zadmin/task/complete')}}?task_id={{$data->id}}" class="btn btn-success">完成</a>
                    @endif
                  </td>
                </tr>
               
              </table>
            </div>
          </div>
      </div>
      <div class="card-box">
          <h2 class="m-t-0 header-title">项目信息</h2>
          <div class="row">
            <div class="col-md-12">
              <table class="table">
                <tr>
                <th>项目类别</th>
                <th>项目名称</th>
                <th>原价</th>
                <th>折扣率</th>
                <th>费用</th>
                
                
                </tr>
                       @foreach($data->service as $pro)
                       <tr>
                        <td>

                     {{object_get($pro,'service_type')}}</td>
                      <td>
                        {{object_get($pro,'service_name')}} 
                        </td>
                        <td>
                          {{$pro->service_price}} 
                      </td>
                      <td>
                          {{$pro->source_price}} 
                      </td>
                      <td>
                          {{$pro->discount}} 
                      </td>
                     
                      </tr>
                       @endforeach
                        </table>
                     </div>
                   </div>
        </div>

        @if($data->depart->count()>0)
        <div class="card-box">
          <h2 class="m-t-0 header-title">配件信息</h2>
          <div class="row">
            <div class="col-md-12">
              <table class="table">
                <tr>
                
                <th>配件名称</th>
                <th>配件数量</th>
                <th>配件单价</th>
                <th>折扣率</th>
                <th>费用</th>
                
                </tr>
                       @foreach($data->depart as $d)
                       <tr>
                        <td>

                    {{$d->depart_name}}</td>
                      <td>
                        {{$d->depart_num}} &nbsp;&nbsp; 
                        </td>
                        <td>{{$d->depart_price}}</td>
                        <td>{{$d->discount}}</td>
                        <td>
                          {{$d->total_price}}
                      </td>
                     
                      </tr>
                       @endforeach
                        </table>
                     </div>
                   </div>
        </div>
      @endif                          
      </div> <!-- end col -->
    </div>  

                            
                      
@endsection
                        
  @section('js')
  <script src="{{asset('admin/js/jquery.printPage.js')}}"></script>
  <script type="text/javascript">
      $(document).ready(function() {
        document.title = '';
        $(".btnPrint").printPage({
          url:"{{url('zadmin/task/print',$data->id)}}",
          attr:"href",
        });
      });

    $('.task-btn').on('click',function(){
      var status = $(this).data('status');
      $('input[name="status"]').val(status);
      $('#form1').submit();
    });
    
  </script>


@endsection                      
                        

                  
            
        
       

           



    
        
    
